# exercise1.erb
# mario hsieh


# string practice

word = "this is a STRING."

puts word.capitalize  # capitalizes the first letter of a string
puts word.upcase # capitalizes all the letters
puts word.downcase # makes all the letters lowercase
puts word.empty? # returns false if string variable is empty
puts word.include?("this")
puts word.length # returns the length of the string
puts word[5] # returns the 6 letter of the string
puts word.split("") # splits the string into an array



# array practice

names = ["Alfie", "Bruce", "Candy", "Dana", "Eva"]

numbers = [11,12,13,14,15]

# return certain elements of an array
puts names[1]
puts numbers[3]

# returns the array clas
puts numbers.class

# shuffles the elements of an array
puts names.shuffle

# connects array with a symbol
puts numbers.join(".")

# displays array as a string
puts numbers.to_s

# delete an element of an array
puts numbers.delete(15)

# add an element to an array
numbers.push(16)
puts numbers

# remove the last element of an array
puts numbers.pop

# finds the length of the array
puts names.length

# reverses the order of the array
puts numbers.reverse



# range practice

puts (1..5).to_a

puts (1...5).to_a

x = (1...5)

puts "yes, 5 is included!" if x.include? 5

puts "yes, 5 is included!" if x.member? 5

letters = ('a'...'z')

puts letters.to_a.shuffle.to_s

puts letters.last

puts x.max

puts x.min



# hash practice

hashy = {"a" => "one", "b" => "two", "c" => "three", "d" => "four", "e" => "five"}


puts hashy.delete("c")

puts hashy.empty?

puts hashy.has_key?("e")

puts hashy.has_value?("six")

def alpha
	yield	
	puts "the sky is blue"
	puts "it's cold today"
	yield
end

alpha { puts "block party tomorrow" }

def beta
	yield (10)	
	puts "the sky is gray"
	puts "it's hot outside!"
	yield (15)
end

beta {|i| puts "block party around the corner in #{i} minutes" }

def delta(num)
	puts "my favorite number is #{num}"
	puts "#{num} times 7 is #{yield(num)}"
end

delta(3) {|i| i*7 }




















